"""@Project -> File   ：python -> 03.回合制游戏
   @IDE    ：PyCharm
   @Author ：PengLinxi
   @Date   ：2021/12/13 10:32
"""
# 回合制对战游戏
# • 创建角色：名字、性别、血量、装备      • 战斗
# • 创建房间：                       • 装备-防弹衣
# • 角色可加入房间                    • 血量默认100
# • 房间内的人可互打                  • 正常被攻击-10滴血
# • 房间上限2人                      • 有防弹衣-5滴血


import random

class Character:

    role={}

    def __init__(self,name,sex):
        self.name = name
        self.sex = sex
        self.blood = 100
        self.equip=self.get_equip()
        Character.role[self.name]=self.equip



    def get_equip(self):

        switcher  = {
        0:'赤手空拳',
        1:'屠龙刀',
        2:'九阴白骨爪',
        3:'葵花点穴手',
        4:'排山倒海',
        5:'降龙十八掌',
        6: '倚天剑',
        }

        return  switcher.get(random.randint(0, 6))

    def combat(self,value):
        for k,v in value.items():
            role1=k
            role2=v
            # for k,v in Character.role.items():
            #     dict={}
            #     if role1==k:
            #         print(f"{k}拥有{v}")
            #         if v == "赤手空拳":
            #             dict[k]=5
            #         else:
            #         dict[k]=10
            #     if role2==k:
            #         print(f"{k}拥有{v}")
            #         if v == "赤手空拳":
            #             dict[k] = 5
            #         else:
            #             dict[k] = 10


            for k, v in Character.role.items():
                kv1=None
                kv2=None
                if k==role1:
                    kv1=v
                if k==role2:
                    kv2=v
                if kv1=="赤手空拳" and kv2=="赤手空拳":
                    print(f"{kv1}赢")
                if kv1=="赤手空拳" and kv2!="赤手空拳":
                    print(f"{kv2}赢")
                if kv1!= "赤手空拳"and kv2=="赤手空拳":
                    print(f"{kv1}赢")



class Room:

    room_list={}

    def __init__(self,room_num,character_name):
        self.room_num=room_num
        self.character_name=character_name
        # Room.room_list={character_name:room_num}
        Room.room_list[character_name]=room_num
        self.value=Room.judge_room(self,Room.room_list,self.character_name,self.room_num)

    def judge_room(self,room_list,character_name,room_num):
        self.character_name=character_name
        self.room_num=room_num
        for k,v in room_list.items():
            dict = {}
            if self.character_name!=k:
                if self.room_num ==v:
                    print(f"{self.character_name}和{k}已组成房间{v}，开始战斗")
                    # dict={}
                    dict[k]=self.character_name
                    self.dict=dict
                    return dict

        print(Room.room_list)


print("===========回合制对战游戏=================")
while 1:
    print("请先创建角色")
    name=input("请输入创建的角色名：")
    sex=input("请输入创建的角色性别：")
    character1=Character(name,sex)
    # print(character1.name,character1.sex,character1.blood,character1.equip)
    room_num=input("请选择房间:")
    room1= Room(room_num,character1.name)
    # print(room1.value)
    if room1.value!=None:
       character1.combat(room1.value)